﻿using System.Collections.Generic;
using Updater.Common.Database;
using System.Linq;
using System.Text;
using log4net;
using System;


namespace Updater.Common
{
    public class DatabaseInstaller
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(DatabaseInstaller));

        private void Connect()
        {
            try
            {
              //  bool result = SqlScripting.BuildStringAndInitConnection(txtSqlServerInstance.Text, txtUsername.Text, txtPassword.Text);
            }
            catch(Exception exception)
            {
                log.Error("could not connecto to the database", exception);
            }
        }


           

        public bool Install()
        {
            try
            {
                Connect();
                log.Debug("Install() called");
                // Perform database creation
                string dbConnectionString = SqlScripting.InstallDatabase();
                log.Debug("Fetched Connection string was:" + dbConnectionString);
                return true;
                
            }
            catch(Exception exception)
            {
                log.Error("Problem detected while executing database script", exception);
                return false;
            }
        }


        
    }
}
